home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / M / Lex.cpt / Lex / ABC.LXI next >
Text File  |  1990-04-20  |  730b  |  31 lines

  1. /*
  2.  * An example lex input file to show the effects of quotes,
  3.  * apostrophes, and upper and lower case letters.
  4.  */
  5.  
  6. c = [C];
  7. break = [;];    /* to test the effect */
  8. illegal = [0-9];
  9. ignore = [,./;:];
  10. %{
  11. #include    <stdlib.h>
  12.  
  13. main()
  14. {
  15.     int token_number;
  16.     while(token_number = yylex())
  17.         printf("\nyylex returns %d\n", token_number);
  18.     printf("\nyylex returns NULL\n");
  19. }
  20. %}
  21.  
  22. %%
  23. 'a'            {            printf("yylex: a\n");   return(1);}
  24. 'A'            {            printf("yylex: A\n");   return(2);}
  25. "b"            {            printf("yylex: b\n");   return(3);}
  26. "B"            {            printf("yylex: B\n");   return(4);}
  27. C            {            printf("yylex: c\n");   return(5);}
  28. c            {            printf("yylex: C\n");   return(6);}
  29. [\n\r\t ]    {            printf("yylex: white space\n"); return(LEXSKIP);}
  30. %%
  31. void yyinit() {}